@import '../common/style/base.less';

@indexes-anchor-color: var(--td-indexes-anchor-color, @text-color-primary);
@indexes-anchor-active-color: var(--td-indexes-anchor-active-color, @brand-color);
@indexes-anchor-bg-color: var(--td-indexes-anchor-bg-color, @bg-color-secondarycontainer);
@indexes-anchor-active-bg-color: var(--td-indexes-anchor-active-bg-color, @bg-color-container);
@indexes-anchor-font: var(--td-indexes-anchor-font, @font-body-medium);
@indexes-anchor-active-font-weight: var(--td-indexes-anchor-active-font-weight, 600);
@indexes-anchor-offset-top: var(--td-indexes-anchor-top, 0); // 锚点吸顶时与顶部的距离
@indexes-anchor-padding: var(--td-indexes-anchor-padding, 8rpx 32rpx);
@indexes-anchor-border-color: var(--td-indexes-anchor-border-color, @component-border);

.@{prefix}-indexes-anchor {
  color: @indexes-anchor-color;
  font: @indexes-anchor-font;

  &__header {
    display: none;
    padding: @indexes-anchor-padding;
    background-color: @indexes-anchor-bg-color;

    &--active {
      background-color: @indexes-anchor-active-bg-color;

      .border(bottom, @indexes-anchor-border-color);
    }
  }

  &__slot {
    overflow: hidden;
  }

  &__slot:empty + &__header {
    display: block;
  }

  &__wrapper {
    will-change: transform;

    &--sticky {
      position: fixed;
      top: @indexes-anchor-offset-top;
      left: 0;
      width: 100%;
      z-index: 1;
    }

    &--active {
      color: @indexes-anchor-active-color;
      font-weight: @indexes-anchor-active-font-weight;
    }
  }
}
